﻿/*******************************************************
* Copyright (c) 2018-2088, By XuXiang all rights reserved.
*
* FileName: ServerGame.cpp
* Summary: 游戏服务模块。
*
* Author: XuXiang
* Date: 2024-04-10 15:01
*******************************************************/

#include "ServerGame.h"
#include "CommandProcesser.h"
#include "../Module/Login/LoginModule.h"
#include "../Module/Match/MatchModule.h"
#include "../Module/Fight/FightModule.h"
#include <Frame/NetManagerBase.h>
#include <Frame/StartSetting.h>
using namespace Competition::Net;

namespace Competition
{
	ServerGame::ServerGame() : m_LoginModule(NULL)
	{	
	}

	ServerGame::~ServerGame()
	{
		m_LoginModule = NULL;
	}

	void ServerGame::OnInit()
	{
		m_LoginModule = GetModule<LoginModule>();
		CommandProcesser::GetInstance()->Init(this);
	}

	void ServerGame::OnRelease()
	{
		m_LoginModule = NULL;
	}

	void ServerGame::OnCommand(const std::string& cmd, const std::vector<std::string> &param)
	{
		CommandProcesser::GetInstance()->OnCommand(cmd, param);
	}

	void ServerGame::OnInitModules()
	{
		AddModules(new LoginModule());
		AddModules(new MatchModule());
		AddModules(new FightModule());
	}

	void ServerGame::OnConnect(UInt64 uid)
	{
		m_LoginModule->OnConnect(uid);
	}

	void ServerGame::OnDisconnect(UInt64 uid)
	{
		m_LoginModule->OnDisconnect(uid);
	}
}